﻿using System.Web.Services;
using static Newtonsoft.Json.JsonConvert;
using static WeatherComm.Log;
using City = EF_Data.City;

namespace WebServiceTest
{
    /// <summary>
    /// WebServiceTest 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消注释以下行。 
    // [System.Web.Script.Services.ScriptService]
    public class WebServiceTest : System.Web.Services.WebService
    {

        [WebMethod(Description = "Hello world Test")]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod(Description = " Test1 测试")]
        public string Test1(string name, int old)
        {
            return $"{name}_{old}";
        }

        [WebMethod(Description = "Test2 测试")]
        public string Test2(City city)
        {
            if (city == null)
            {
                return "Error xxxx";
            }
            var s = SerializeObject(city);
            WriteLog(s);
            return s;
        }
    }
}
